home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / LIBRARY / PASCALL / MARYLAND / P3-1992.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1993-01-31  |  1.9 KB  |  91 lines

  1. {Copyright (c)-Fernando Padilla January 19, 1993}
  2. program problem3at1992;
  3. uses
  4.      p31992u,crt;
  5.  
  6. function rectangles:word;
  7. var
  8.      numberofrectangles:word;
  9.      x:word;
  10.      point1,point2:pointtype;
  11. begin
  12.      numberofrectangles:=0;
  13.      x:=0;
  14.      repeat
  15.           gotolinenumber(x);
  16.           while not(pos('1',linepointing^.image)=0) do
  17.           begin
  18.                point1.x:=x;
  19.                point1.y:=pos('1',linepointing^.image);
  20.                point2.x:=point1.x;
  21.                point2.y:=point1.y;
  22.                expand(point2);
  23.                if testrectangle(point1,point2) then
  24.                begin
  25.                     clearrectangle(point1,point2);
  26.                     inc(numberofrectangles);
  27.                end;
  28.           end;
  29.           gotolinenumber(x);
  30.           inc(x);
  31.      until linepointing^.next=nil;
  32.      rectangles:=numberofrectangles;
  33. end;
  34.  
  35. procedure batchinputdata(var batchfile:text);
  36. var
  37.      temp:string[80];
  38.      batchingfile:text;
  39. begin
  40.      assign(batchingfile,'a:p3-data.dat');
  41.      reset(batchingfile);
  42.  
  43.      repeat
  44.           readln(batchingfile,temp);
  45.           writeln(temp);
  46.           writeln(batchfile,temp);
  47.      until eof(batchingfile);
  48.      close(batchingfile);
  49. end;
  50.  
  51. procedure inputdata(var batchfile:text);
  52. var
  53.      temp:string[80];
  54. begin
  55.      linepointing:=nil;
  56.      repeat
  57.           readln(temp);
  58.           writeln(batchfile,temp);
  59.      until eof;
  60. end;
  61.  
  62. procedure outputdata(var batchfile:text);
  63. begin
  64.      reset(batchfile);
  65.      repeat
  66.           addimage(batchfile);
  67.           writeln(rectangles);
  68.           removeimage;
  69.      until eof(batchfile);
  70. end;
  71.  
  72. procedure control;
  73. var
  74.      batchfile:text;
  75. begin
  76.      clrscr;
  77.      assign(batchfile,'a:tempfile.dat');
  78.      rewrite(batchfile);
  79.  
  80. {     inputdata(batchfile);}
  81.      batchinputdata(batchfile);
  82.      outputdata(batchfile);
  83.      close(batchfile);
  84.      erase(batchfile);
  85. end;
  86.  
  87.  
  88. begin
  89.      control;
  90. end.
  91.